#pragma once

#include <linux/const.h>
#include <asm/bitsperlong.h>
#include <linux/types.h>

#define BIT_MASK(nr) ((unsigned long)1 << ((nr) % BITS_PER_LONG))
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)

#define BIT(nr) (1UL << (nr))

#define BITS_PER_BYTE 8

#define GENMASK_TYPE(t, h, l, bpl)       \
        (((~(t)0) - ((t)1 << (l)) + 1) & \
         (~(t)0 >> (bpl - 1 - (h))))

#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l, BITS_PER_LONG)
#define GENMASK_ULL(h, l) GENMASK_TYPE(u64, h, l, 64)

#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
